package com.example.demomybatis.mapper;

import com.example.demomybatis.entity.Course;
import com.example.demomybatis.entity.Student;
import com.example.demomybatis.vo.RequestCoursePr;
import com.example.demomybatis.vo.RequestStudentPr;
import org.apache.ibatis.annotations.*;
import org.springframework.stereotype.Repository;

import java.util.List;

@Repository
public interface StudentMapper {

    Integer  addStudent(Student student);

    @Delete("delete from  student where student_id = #{studentId}")
    Integer  deleteStudent(Integer studentId);


    List<Student> selectStudent(RequestStudentPr requestStudentPr);


    Integer selectCountStudent (RequestStudentPr requestStudentPr);

    @Select("select * from student where student_id =  #{studentId}")
    @Results({
            @Result(property = "studentId",column = "student_id"),
            @Result(property = "studentName",column = "student_name"),
            @Result(property = "studentBirthday",column = "student_birthday"),
            @Result(property = "studentSex",column = "student_sex"),
    })
    Student selectOneStudent(Integer studentId);


    @Update("update student set student_name = #{studentName},student_birthday = #{studentBirthday},student_sex = #{studentSex} where student_id = #{studentId}")
    Integer  updateStudent(Student student);
}
